package proyecto.testcasetool.provider.main;

import java.util.Collection;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EStructuralFeature;

import proyecto.testcasetool.TestcasetoolPackage;
import proyecto.testcasetool.UseCaseModel;
import proyecto.testcasetool.provider.UseCaseModelItemProvider;

public class UseCaseModelItemProviderMain extends UseCaseModelItemProvider {

	public UseCaseModelItemProviderMain(AdapterFactory adapterFactory) {
		super(adapterFactory);
	}

	protected Collection children = null;
	protected ActorsGhostItemProvider actorsItemProvider = null;
	
	@Override
	public Collection<?> getChildren(Object object) {
		UseCaseModel model = (UseCaseModel) object;
		if (actorsItemProvider == null){
			this.actorsItemProvider = new ActorsGhostItemProvider(adapterFactory, model);
		}
		children = super.getChildren(object);
		children.add(this.actorsItemProvider);
		
		return children;
		
	}

	
	@Override
	public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
		if (childrenFeatures == null) {
			super.getChildrenFeatures(object);
			childrenFeatures.remove(TestcasetoolPackage.Literals.USE_CASE_MODEL__ACTOR);
		}
		return childrenFeatures;
	}
	
	public Object getActors() {
		return this.actorsItemProvider;
	}

	
	@Override
	protected void collectNewChildDescriptors(
			Collection<Object> newChildDescriptors, Object object) {
		super.collectNewChildDescriptors(newChildDescriptors, object);
	}

	/**
	 * Disposes the non-modeled children.
	 */
	@Override
	public void dispose() {
		super.dispose();
		if (children != null) {
			actorsItemProvider.dispose();
		}
	}

}
